package com.infoDiffusion.util;

import java.io.FileInputStream;
import java.util.List;
import java.util.Properties;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

public class InitServlet extends HttpServlet{
	private static final long serialVersionUID = 1L;

	@Override
	public void init(ServletConfig config) throws ServletException {
		String path;
		FileInputStream fis;
		try {
			path = InitServlet.class.getResource("/").getPath();
			fis = new FileInputStream(path+"conf.properties");
			Properties properties = new Properties();
			properties.load(fis);
			fis.close();
			/*System.out.println("path:"+path);
			System.out.println();*/
			String baseUpload = properties.getProperty("baseUpload");
			if(baseUpload!=null) {
				Constants.UPLOAD_BASE = baseUpload;
				Constants.UPLOAD_PRODUCT_LIST = Constants.UPLOAD_BASE+"pic/";
			}
			String baseShow = properties.getProperty("baseShow");
			if(baseShow!=null) {
				Constants.SHOW_BASE = baseShow;
				Constants.SHOW_PRODUCT_LIST = Constants.SHOW_BASE+"pic/";
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
}
